Skip to content

fix(umg): bind_on_hovered and bind_on_value_changed author real bound-event nodes#482

Merged
ChiR24 merged 2 commits into
ChiR24:devfrom
SoloGorilla:fix/umg-event-bindings-real-nodes
Jul 7, 2026
Merged

fix(umg): bind_on_hovered and bind_on_value_changed author real bound-event nodes#482
ChiR24 merged 2 commits into
ChiR24:devfrom
SoloGorilla:fix/umg-event-bindings-real-nodes

Conversation

@SoloGorilla

Copy link
Copy Markdown
Contributor

Problem

bind_on_hovered and bind_on_value_changed returned a plain instruction string (e.g. "Bind 'OnButtonHovered' to BtnStart's OnHovered event.") instead of authoring anything — no node, no nodeId. Only bind_on_clicked created a real UK2Node_ComponentBoundEvent.

Fix (EventBindings.cpp)

Extracted the working bind_on_clicked implementation into a shared BindComponentDelegateEvent helper and routed the other two through it:

  • bind_on_hovered → Button OnHovered.
  • bind_on_value_changed → per widget type: Slider/SpinBox OnValueChanged, CheckBox OnCheckStateChanged, ComboBoxString OnSelectionChanged; unsupported widgets return UNSUPPORTED_WIDGET rather than a misleading success.

Both now author a real UK2Node_ComponentBoundEvent (returns nodeId + compileSucceeded), are idempotent (reuse an existing bound event via FindBoundEventForComponent), and only dirty/recompile when something actually changed — matching bind_on_clicked exactly. create_property_binding is intentionally left unchanged (separate follow-up).

Validation (UE 5.8, live)

bind_on_hovered (Button) and bind_on_value_changed (Slider) both produce real K2Node_ComponentBoundEvent nodes (OnButtonHoverEvent / OnFloatValueChangedEvent) with compileSucceeded:true.

🤖 Generated with Claude Code

…-event nodes

bind_on_hovered and bind_on_value_changed returned an instruction string ("Bind '...' to ...'s
... event.") instead of authoring a node, unlike bind_on_clicked which creates a real
UK2Node_ComponentBoundEvent.

Extracted the working bind_on_clicked path into a shared BindComponentDelegateEvent helper and
routed both actions through it:
- bind_on_hovered -> Button OnHovered.
- bind_on_value_changed -> per widget type: Slider/SpinBox OnValueChanged, CheckBox
  OnCheckStateChanged, ComboBoxString OnSelectionChanged; unsupported widgets return
  UNSUPPORTED_WIDGET instead of a misleading success.

Both now return a real node (nodeId + compileSucceeded), are idempotent (reuse an existing bound
event), and only dirty/recompile when something changed. create_property_binding is left unchanged.

Verified live in UE 5.8: bind_on_hovered and bind_on_value_changed (Slider) both produce real
K2Node_ComponentBoundEvent nodes with compileSucceeded:true.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1e496a64-e230-4206-b70d-c1c980c17c00

📥 Commits

Reviewing files that changed from the base of the PR and between 3cae682 and 46b79fb.

📒 Files selected for processing (1)
  • plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Expanded widget event binding for value-changed interactions across sliders, spin boxes, checkboxes, and combo boxes.
    • Improved event binding behavior for button clicked and hovered actions with consistent binding responses.
  • Bug Fixes

    • Added structured, detailed responses for event binding outcomes (including whether bindings were reused or created and whether compilation succeeded).
    • Reduced unnecessary blueprint recompiles by recompiling only when structural updates occur.
    • Improved unsupported widget handling with clear, structured error details.

Walkthrough

A shared helper now creates or reuses component-bound event nodes for widget delegate bindings, conditionally recompiling only when the blueprint structure changes. The clicked, hovered, and value-changed widget handlers now route through that helper, including widget-type-based delegate selection for value changes.

Changes

Widget Event Binding Refactor

Layer / File(s) Summary
BindComponentDelegateEvent core helper
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp
Adds a shared helper that resolves the multicast delegate and component variable, finds or creates a UK2Node_ComponentBoundEvent idempotently, marks the blueprint structurally modified and recompiles only on structural changes, and returns structured JSON with binding and editor node/compile details; missing resource cases emit automation errors.
Widget binding handlers call helper
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp
Routes bind_on_clicked and bind_on_hovered through the shared helper, and refactors bind_on_value_changed to choose the delegate name by widget type before calling the helper; unsupported widget types now emit a structured automation error.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • ChiR24/Unreal_mcp#454: Adjusts the same widget event binding area to author real UK2Node_ComponentBoundEvent nodes for button click bindings.

Suggested reviewers: ChiR24

Poem

🐇 Hop, hop, a helper grew bright,
Binding widget events feels just right.
Clicked, hovered, value change too,
One tidy path for me and you.
A bunny nods at the compile glow —
Fewer branches, let the blueprints flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: authoring real bound-event nodes for hovered and value-changed handlers.
Description check ✅ Passed The description covers the problem, fix, and validation well, though it omits some template sections like Related Issues and checklist items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp (1)

25-116: ⚡ Quick win

Route bind_on_clicked through the helper as well.

The new helper duplicates the full OnClicked binding path, but bind_on_clicked still keeps its own copy. That means fixes like the structural-dirtying issue above must be patched twice. The helper signature already supports ButtonWidget, UButton::StaticClass(), and OnClicked, so the clicked handler can delegate after validation.

Also applies to: 159-237

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp`
around lines 25 - 116, The bind_on_clicked handler is duplicating the full
binding logic instead of using the new BindComponentDelegateEvent helper
function that was created. Locate the bind_on_clicked handler implementation and
refactor it to call BindComponentDelegateEvent with the appropriate parameters
(TargetWidget as ButtonWidget, DelegateOwnerClass as UButton::StaticClass(),
DelegateName as OnClicked, and other metadata) instead of implementing the same
logic directly. This eliminates code duplication and ensures that any future
fixes to the binding process only need to be applied once in the helper
function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp`:
- Around line 85-100: When creating a new UK2Node_ComponentBoundEvent node in
the EventGraph, the code marks the Blueprint as modified via
MarkBlueprintAsModified but fails to mark it as structurally modified. Graph
node creation is a structural change to the Blueprint, so you need to add a call
to MarkBlueprintAsStructurallyModified in addition to MarkBlueprintAsModified.
Specifically, when bCreatedNew is true (indicating a new BoundNode was created),
call FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified on the WidgetBP
before or after the MarkBlueprintAsModified call to properly notify the
Blueprint system of the structural change.

---

Nitpick comments:
In
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp`:
- Around line 25-116: The bind_on_clicked handler is duplicating the full
binding logic instead of using the new BindComponentDelegateEvent helper
function that was created. Locate the bind_on_clicked handler implementation and
refactor it to call BindComponentDelegateEvent with the appropriate parameters
(TargetWidget as ButtonWidget, DelegateOwnerClass as UButton::StaticClass(),
DelegateName as OnClicked, and other metadata) instead of implementing the same
logic directly. This eliminates code duplication and ensures that any future
fixes to the binding process only need to be applied once in the helper
function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7deb5908-9bba-4d14-95af-530dde7d3ab7

📥 Commits

Reviewing files that changed from the base of the PR and between e1ceb64 and 3cae682.

📒 Files selected for processing (1)
  • plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/WidgetAuthoring/Bindings/McpAutomationBridge_WidgetAuthoringEventBindings.cpp

@SoloGorilla

Copy link
Copy Markdown
Contributor Author

On adding MarkBlueprintAsStructurallyModified to the node-creation path: this helper (BindComponentDelegateEvent) is a faithful extraction of the existing bind_on_clicked, which uses the same pattern — structural-modify only when toggling bIsVariable, then MarkBlueprintAsModified + recompile on node creation — and produces working, compiled bound-event nodes. Both bind_on_hovered (Button) and bind_on_value_changed (Slider) were live-validated in UE 5.8 with compileSucceeded:true and real K2Node_ComponentBoundEvent nodes. I kept it consistent with bind_on_clicked rather than diverging one path; happy to add the structural mark to all three (incl. bind_on_clicked) if you'd prefer it.

…elper

Review follow-up, both findings:
- bind_on_clicked now delegates to BindComponentDelegateEvent after its
  Button lookup, removing the duplicated binding path so future fixes
  land in one place. Response contract is unchanged (same fields, same
  "OnClicked event bound" message).
- BindComponentDelegateEvent marks the Blueprint structurally modified
  when it creates a new bound-event node — the same call the Designer's
  FKismetEditorUtilities::CreateNewBoundEventForComponent path makes —
  which now covers all three bind actions.
@github-actions github-actions Bot added size/l and removed size/m labels Jul 6, 2026
@SoloGorilla

Copy link
Copy Markdown
Contributor Author

Both review findings addressed and pushed:

  1. bind_on_clicked now delegates to BindComponentDelegateEvent after its Button lookup — the duplicated binding path is gone (net −70 lines), so future fixes land once in the helper. Response contract unchanged (same fields, same "OnClicked event bound" message).
  2. The helper now calls FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified when it creates a new bound-event node — the same call the Designer's FKismetEditorUtilities::CreateNewBoundEventForComponent path makes — and since all three bind actions share the helper, this covers bind_on_clicked / bind_on_hovered / bind_on_value_changed uniformly.

Live-verified in a UE 5.8 editor on a fresh widget blueprint: bind_on_clicked (via the helper) → real K2Node_ComponentBoundEvent, compileSucceeded:true; repeat call → createdNew:false with the same node GUID (idempotent reuse intact); bind_on_hovered and bind_on_value_changed (Slider) → real nodes; graph readback confirms all three bound-event nodes present with matching GUIDs.

@ChiR24
ChiR24 merged commit e8ab693 into ChiR24:dev Jul 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants